//
//  FoodProtocol.swift
//  eat_known
//
//  Created by 心情 on 2018/7/26.
//  Copyright © 2018年 心情. All rights reserved.
//

import Foundation
import HandyJSON

enum FoodSource: String {
    case Unknown  = "未知"
    case LadyBird = "孕期提醒"
    case BabyTree = "宝宝树"
    case AliPay   = "支付宝"
    case Steward  = "怀孕管家"
}

class Food: HandyJSON {
    var source: FoodSource = .Unknown
    var name: String?
    var desc: String?
    var imageURL: URL?
    var detailURL: URL?
    var phaseList: Array<Phase>?
    
    required init() {
    }
    
    init(_ type: FoodSource) {
        source = type
    }
    
    func mapping(mapper: HelpingMapper) {
        mapper <<< name <-- ["title", "name"]
        mapper <<< detailURL <-- ("url", URLTransform())
        mapper <<< imageURL <-- (["image", "thumb"], URLTransform())
        mapper <<< desc <-- ["description", "introduction"]
        mapper <<< phaseList <-- ["know", "crowdRecords"]
    }
}
